package com.bnyy.message.bean.chat;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import org.xutils.db.annotation.Column;
import org.xutils.db.annotation.Table;

import java.io.Serializable;
import java.util.ArrayList;

/**
 * Author : 关炳鹏
 * Description :
 * Date : 2022/12/12
 **/
@Table(name = "message_chat_info")
public class ChatInfo implements Serializable {

    public interface ColumnName {
        String CHAT_ID = "chat_id";
        String HEADERS_JSON = "headers_json";
        String CHAT_NAME = "chat_name";
        String TOPPING = "topping";
        String NO_DISTURB = "no_disturb";
    }

    /**
     * 普通消息 {loginId}_{recipientId}
     * 其他消息 {loginId}_{{@link com.bnyy.message.enums.MessageType}}
     */
    @Column(name = ColumnName.CHAT_ID, isId = true, autoGen = false)
    private String chatId;

    @Column(name = ColumnName.CHAT_NAME)
    private String chatName;

    @Column(name = ColumnName.HEADERS_JSON)
    private String headersJson;

    @Column(name = ColumnName.TOPPING)
    private boolean topping;

    @Column(name = ColumnName.NO_DISTURB)
    private boolean noDisturb;

    public ChatInfo() {
    }

    public ChatInfo(String chatId) {
        this.chatId = chatId;
    }

    public String getChatId() {
        return chatId;
    }

    public void setChatId(String chatId) {
        this.chatId = chatId;
    }

    public void setChatName(String chatName) {
        this.chatName = chatName;
    }
    public String getChatName() {
        return chatName;
    }

    public void setHeadersJson(String headersJson) {
        this.headersJson = headersJson;
    }

    public String getHeadersJson() {
        return headersJson;
    }

    public boolean isTopping() {
        return topping;
    }

    public void setTopping(boolean topping) {
        this.topping = topping;
    }

    public boolean isNoDisturb() {
        return noDisturb;
    }

    public void setNoDisturb(boolean noDisturb) {
        this.noDisturb = noDisturb;
    }

    public ArrayList<String> getHeaders() {
        return new Gson().fromJson(getHeadersJson(), new TypeToken<ArrayList<String>>() {
        }.getType());
    }
}
